package com.hspedu.newData.dmsxl.数组.二分查找;

import org.junit.Test;

/**
 * @Author: yh
 * @description: 
 * @CreateTime: 2025-04-22 
 * @Version: 1.0
 */

public class LC69X的平方根 {

    public int mySqrt(int x) {

        int left = 0;
        int right = x;
        while(left <= right){
            int mid = left + (right-left) / 2;

            if (x / mid >  mid){
                left = mid + 1;
            }else if (x / mid < mid){
                right = mid - 1;
            }else {
                return mid;
            }
        }
        return right;
    }

    @Test
    public void test(){

        int i = mySqrt(2147395599);
        System.out.println("====");
    }
}
